package com.qianfeng.gl4study.youshare.model;

import android.database.Cursor;

/**
 * Created with IntelliJ IDEA.
 * I'm glad to share my knowledge with you all.
 * User:Gaolei
 * Date:2015/2/25
 * Email:pdsfgl@live.com
 */
public class CollectItem {

	//
	private long _id;

	public long get_id() {
		return _id;
	}

	//当前商品数量
	private int count;
	//商品是否被选中
	private boolean checked;
	//商品信息的Id，区分商品
	private String productId;
	//商品单价
	private float productPrice;

	//商品的名称
	private String productName;

	//商品的缩略图
	private String productThumb;

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public boolean isChecked() {
		return checked;
	}

	public void setChecked(boolean checked) {
		this.checked = checked;
	}

	public String getProductId() {
		return productId;
	}

	public void setProductId(String productId) {
		this.productId = productId;
	}

	public float getProductPrice() {
		return productPrice;
	}

	public void setProductPrice(float productPrice) {
		this.productPrice = productPrice;
	}

	public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}

	public String getProductThumb() {
		return productThumb;
	}

	public void setProductThumb(String productThumb) {
		this.productThumb = productThumb;
	}




	public void parseCursor(Cursor query) {
		if(query!=null) {
			int index = query.getColumnIndex("productId");
			if (index != -1) {
				productId = query.getString(index);
			}
			index = query.getColumnIndex("productName");
			if (index != -1) {
				productName = query.getString(index);
			}
			index = query.getColumnIndex("productPrice");
			if (index != -1) {
				productPrice = query.getFloat(index);
			}
			index = query.getColumnIndex("productThumb");
			if (index != -1) {
				productThumb = query.getString(index);
			}
			index = query.getColumnIndex("count");
			if (index != -1) {
				count = query.getInt(index);
			}
			index = query.getColumnIndex("checked");
			if (index != -1) {
				int i = query.getInt(index);
				if(i==1){
					checked = true;
				}else {
					checked = false;
				}
			}

			index = query.getColumnIndex("_id");
			if (index!=-1){
				_id = query.getLong(index);
			}
		}

	}
}
